﻿using System.Collections.Generic;
using System.Linq;
using CodeCamp.BL.UI;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CodeCamp.Tests
{
	/// <summary>
	///This is a test class for MvcTagCloudTest and is intended
	///to contain all MvcTagCloudTest Unit Tests
	///</summary>
	[TestClass]
	public class MvcTagCloudTest
	{
		[TestMethod]
		[DeploymentItem("CodeCamp.BL.dll")]
		public void quantize_1to10quant10_quantizes()
		{
			var expected = new Dictionary<string, int>();

			expected["item1"] = 1;
			expected["item2"] = 2;
			expected["item3"] = 20;
			expected["item4"] = 144;
			expected["item5"] = 20;
			expected["item6"] = 6;
			expected["item7"] = 7;
			expected["item8"] = 88;
			expected["item9"] = 9;
			expected["item10"] = 100;


			Dictionary<string, int> actual = MvcTagCloud_Accessor.quantize(expected);


			Assert.IsNotNull(actual);
		}


		[TestMethod]
		[DeploymentItem("CodeCamp.BL.dll")]
		public void quantize_0to10quant5_quantizes()
		{
			var data = new Dictionary<string, int>();
			var actual = new Dictionary<string, int>();

			foreach (int i in Enumerable.Range(0, 11))
			{
				data["item_" + i] = i;
			}

			actual = MvcTagCloud_Accessor.quantize(data);

			for (int i = 0; i < MvcTagCloud_Accessor._Sizes.Length; i++)
			{
				Assert.IsTrue(actual.Any(item => item.Value == i));
			}
		}
	}
}